package org.ccay.sitemap;

import java.util.ArrayList;
import java.util.List;

import org.ccay.core.base.BaseResourceVO;
import org.ccay.core.exception.SystemException;
import org.ccay.core.log.JsonSerializableProperties;
import org.ccay.security.exception.SecuritySystemException;

/**
 * 导航菜单VO
 * 
 * @author chaowangbang
 * @since 2011-10-24
 */
@JsonSerializableProperties(value={"siteNodeId","name","url","description","parent","orderId","target","status","control"})
public class SiteNodeVO extends BaseResourceVO implements Cloneable {
	
	private static final long serialVersionUID = -1485444183797534361L;
	
	/**
	 * 公开可见（可不登录）
	 */
	public static final String VISIBLE_PUBLIC = "4";
	
	/**
	 * 所有人可见（已登录用户）
	 */
	public static final String VISIBLE_TO_EVERYONE = "1";
	/**
	 * 根据子可见
	 */
	public static final String VISIBLE_BY_CHILDREN = "2";
	/**
	 * 根据功能点
	 */
	public static final String VISIBLE_TO_FUNCTION = "3";

	
	/**
	 * 是否发布
	 */
	public static final String STATUS_PUBLISH = "2";
	/**
	 * 节点id
	 */
	private int siteNodeId;
	/**
	 * 父节点id
	 */
	private int parentId;
	/**
	 * 节点名称
	 */
	private String name;
	/**
	 * 节点描述
	 */
	private String description;
	/**
	 * 显示名称
	 */
	private String viewName;
	/**
	 * 所有的可见视图
	 */
	private List<String> visibleView;
	private String visibleViewStr;
	/**
	 * 链接打开的方式
	 */
	private String target;
 
 	/**
	 * 状态，2=Publish，0=未发布
	 */
	private String status;
	/**
	 * 排序号
	 */
	private int orderId;
	/**
	 * 1:所有人都可见permission 2:子节点可见 3:绑定到功能
	 * */
	private String control;
	/**
	 * 绑定的权限点，格式为 resourceCode:operationCode
	 */
	private String permissionString; 
	
	/**
	 * 绑定的权限点，格式为 系统管理|角色管理:创建角色
	 */
	private String permissionName; 
	
	/**
	 * 直接父节点 Created：2011-8-31
	 * 
	 * @author chaowangbang
	 */
	private SiteNodeVO parent = null;
	/**
	 * 直接子节点（非递归所有深度的子节点） Created：2011-8-31
	 * 
	 * @author chaowangbang
	 */
	private List<SiteNodeVO> children = null;
	/**
	 * 是否有子
	 */
	private int hasChild;
	/**
	 * 栏目点击后需要访问的URL地址
	 * */
	private String url; 
	/**
	  *  菜單定位的标识
	 * */
	private String location; 
	
	/**
	 * Font Awesome4.5字体图标;
	 */
	private String faName;
 
	/**
	 * 是否可见
	 * @author chaowangbang
	 * @since 2011-11-22
	 * @return
	 */
	public boolean isVisible(){
		return SiteNodeVO.STATUS_PUBLISH.equals(this.getStatus());		
	}

	/**
	 * @return the siteNodeId
	 */
	public int getSiteNodeId() {
		return siteNodeId;
	}

	/**
	 * @param siteNodeId the siteNodeId to set
	 */
	public void setSiteNodeId(int siteNodeId) {
		this.siteNodeId = siteNodeId;
	}

	/**
	 * @return location
	 */
	public String getLocation() {
		return location;
	}

	/**
	 * @param location
	 */
	public void setLocation(String location) {
		this.location = location;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the viewName
	 */
	public String getViewName() {
		return viewName;
	}

	/**
	 * @param viewName the viewName to set
	 */
	public void setViewName(String viewName) {
		this.viewName = viewName;
	}

	/**
	 * @return the visibleView
	 */
	public List<String> getVisibleView() {
		return visibleView;
	}

	/**
	 * @param visibleView the visibleView to set
	 */
	public void setVisibleView(List<String> visibleView) {
		this.visibleView = visibleView;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the orderId
	 */
	public int getOrderId() {
		return orderId;
	}

	/**
	 * @param orderId the orderId to set
	 */
	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	/**
	 * @return the control
	 */
	public String getControl() {
		return control;
	}

	/**
	 * @param control the control to set
	 */
	public void setControl(String control) {
		this.control = control;
	}


	/**
	 * @return the parent
	 */
	public SiteNodeVO getParent() {
		return parent;
	}

	/**
	 * @param parent the parent to set
	 */
	public void setParent(SiteNodeVO parent) {
		this.parent = parent;
	}

	/**
	 * @return the children
	 */
	public List<SiteNodeVO> getChildren() {
		return children;
	}

	/**
	 * @param children the children to set
	 */
	public void setChildren(List<SiteNodeVO> children) {
		this.children = children;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}
	
	/**
	 * 克隆一个对象的基本属性
	 * @throws CloneNotSupportedException 
	 */
	public SiteNodeVO cloneBaseAttribute() throws SystemException{
		SiteNodeVO tempVO = null;
		try {
			tempVO = (SiteNodeVO) super.clone();
			tempVO.setChildren(new ArrayList<SiteNodeVO>());
		} catch (CloneNotSupportedException e) {
			throw new SecuritySystemException("Clone ResourceDefinitionVO fail.",e);
		}
		return tempVO;
	}

	/**
	 * @return the target
	 */
	public String getTarget() {
		return target;
	}

	/**
	 * @param target the target to set
	 */
	public void setTarget(String target) {
		this.target = target;
	}
	
	/**
	 * @return parentId
	 */
	public int getParentId() {
		return parentId;
	}

	/**
	 * @param parentId
	 */
	public void setParentId(int parentId) {
		this.parentId = parentId;
	}
	
	/**
	 * @return hasChild
	 */
	public int getHasChild() {
		return hasChild;
	}

	/**
	 * @param hasChild
	 */
	public void setHasChild(int hasChild) {
		this.hasChild = hasChild;
	}

	public String getVisibleViewStr() {
		return visibleViewStr;
	}

	public void setVisibleViewStr(String visibleViewStr) {
		this.visibleViewStr = visibleViewStr;
	}

	public String getPermissionName() {
		return permissionName;
	}

	public void setPermissionName(String permissionName) {
		this.permissionName = permissionName;
	}

	public String getPermissionString() {
		return permissionString;
	}

	public void setPermissionString(String permissionString) {
		this.permissionString = permissionString;
	}

	public String getFaName() {
		return faName;
	}

	public void setFaName(String faName) {
		this.faName = faName;
	}

}
